trigger WorkOrder on WorkOrder__c (before update,after update,before insert,after insert,after  delete ) {
    
   
     if(trigger.isBefore)
    {
        if(trigger.isUpdate)
        {
            Cbl_WorkOrderProductToAssert.Cbl_WorkOrderfinish(trigger.new);///其他工单在 客户签字和是否追踪不为空的时候完成
            //WorkOrderSmsHandler.sendSmsInfo(trigger.new, trigger.oldMap);
            Cbl_WorkOrderProductToAssert.Cbl_WorkOrderItem2AssetProject(trigger.new, trigger.oldMap);//工单项目变成仪器项目

        }
        
    }

     if(Trigger.isBefore && trigger.isInsert)Cbl_WorkOrderProductToAssert.Cbl_WorkOrderInstallApply(trigger.new);///新建安装工单的时候从个案带入安装申请
    if(Trigger.isAfter && (trigger.isInsert || Trigger.isUpdate))Cbl_WorkOrderProductToAssert.Cbl_WorkOrderToInstallApply(trigger.new);
    new Triggers()
    // .bind(Triggers.Evt.beforeupdate, new CannotModifyClosedWorkOrderHandler())
    // .bind(Triggers.Evt.afterupdate,new WorkOrderSmsHandler())
    .bind(Triggers.Evt.beforeupdate,new WorkOrderHandle())
    .bind(Triggers.Evt.afterupdate,new WorkOrderHandle())
    .bind(Triggers.Evt.afterupdate, new CaseWeixinHandler())

    .manage();
    if(trigger.isUpdate && trigger.isAfter){
          //  Cbl_WorkOrderProductToAssert.Cbl_WorkOrderProduct(trigger.new, trigger.oldMap);//安装工单生成仪器
             PartsLendingApplicationUtil.workOrderProductBackToDetails(trigger.new, false);
            if(trigger.isUpdate && trigger.isAfter)Cbl_WorkOrderProductToAssert.Cbl_WorkOrderToassert(trigger.new, trigger.oldMap);//安装工单生成仪器
          //  Cbl_WorkOrderProductToAssert.Cbl_WorkOrderProduct_NonAgent(trigger.new,trigger.oldMap);//非代理安装工单 生成仪器

        }
    if(trigger.isAfter && trigger.isDelete) PartsLendingApplicationUtil.workOrderProductBackToDetails(trigger.old, true);
   
}